/*
 * EmployeeBO.java
 *
 * Created on March 5, 2007, 8:07 PM
 *
 */

package edu.byu.isys413.group1E.data;

/**Stores information about an employee, including the full name, address,
 * hire date and fire date, and the pay options.
 *
 * @author Travis Kulbeth
 */
public class EmployeeBO {
    
    private String EmployeeID;
    private String empFirstName;
    private String empMI;
    private String empLastName;
    private String empAddress;
    private String empCity;
    private String empState;
    private String empZip;
    private String empPhone;
    private String empSocSecNum;
    private String hireDate;
    private String fireDate = null;
    private double wageRate;
    private PositionBO position;
    private String password;
    boolean alreadyInDB;
    boolean isDirty;

    /** Creates a new instance of EmployeeBO */
    public EmployeeBO() {
    }
    
    /** Creates a new instance of TransactionBO with an ID
     *@param EmployeeID contains the ID for this Employee
     */
    EmployeeBO(String EmployeeID) {
        setEmployeeID(EmployeeID);
        setIsDirty(true);
    }
    
    /** Returns the employee id
     *@return EmployeeID
     */
    public String getEmployeeID() {
        return EmployeeID;
    }

    /** Sets the employee ID
     *@param EmployeeID contains the id for this Employee
     */
    public void setEmployeeID(String EmployeeID) {
        setIsDirty(true);
        this.EmployeeID = EmployeeID;
    }

    /** Returns the employee's first name
     *@return empFirstName
     */
    public String getEmpFirstName() {
        return empFirstName;
    }

    /** Sets the employee's first name
     *@param empFirstName contains the first name for the employee
     */
    public void setEmpFirstName(String empFirstName) {
        setIsDirty(true);
        this.empFirstName = empFirstName;
    }

    /** Returns the employee's middle initial
     *@return empMI
     */
    public String getEmpMI() {
        return empMI;
    }

    /** Sets the employee's middle initial
     *@param empMI contains the employee's middle initial
     */
    public void setEmpMI(String empMI) {
        setIsDirty(true);
        this.empMI = empMI;
    }

    /** Returns the employee's last name
     *@return empLastName
     */
    public String getEmpLastName() {
        return empLastName;
    }

    /** Sets the employee's last name
     *@param empLastName contains the employee's last name
     */
    public void setEmpLastName(String empLastName) {
        setIsDirty(true);
        this.empLastName = empLastName;
    }
    
    /** Returns the employee's full name
     *@return the employee's full name
     */
    public String getEmpFullName(){
        String fullName = new String(this.empFirstName + " " + this.empMI + " " + this.empLastName);
        return fullName;
    }

    /** Returns the employee's address
     *@return employee's street address
     */
    public String getEmpAddress() {
        return empAddress;
    }

    /** Sets the employee's Address
     *@param empAddress contains the street address
     */
    public void setEmpAddress(String empAddress) {
        setIsDirty(true);
        this.empAddress = empAddress;
    }

    /** Returns the employee's city
     *@return empCity
     */
    public String getEmpCity() {
        return empCity;
    }

    /** Sets the employee's city
     *@param empCity contains the city name
     */
    public void setEmpCity(String empCity) {
        setIsDirty(true);
        this.empCity = empCity;
    }

    /** Returns the employee's state
     *@return empState
     */
    public String getEmpState() {
        return empState;
    }

    /** Sets the employee's state
     *@param empState contains the state's name
     */
    public void setEmpState(String empState) {
        setIsDirty(true);
        this.empState = empState;
    }

    /** Returns the employee's postal (zip) code
     *@return empZip
     */
    public String getEmpZip() {
        return empZip;
    }

    /** Sets the employee's postal (zip) code
     *@param empZip contains the zipcode
     */
    public void setEmpZip(String empZip) {
        setIsDirty(true);
        this.empZip = empZip;
    }

    /** Returns the employee's phone number
     *@return empPhone
     */
    public String getEmpPhone() {
        return empPhone;
    }

    /** Sets the employee's phone number
     *@param empPhone contains the phone number
     */
    public void setEmpPhone(String empPhone) {
        setIsDirty(true);
        this.empPhone = empPhone;
    }

    /** Returns the employee's social security number
     *@return empSocSecNum
     */
    public String getEmpSocSecNum() {
        return empSocSecNum;
    }

    /** Sets the employee's social security number
     *@param empSocSecNum contains the employee's social security number
     */
    public void setEmpSocSecNum(String empSocSecNum) {
        setIsDirty(true);
        this.empSocSecNum = empSocSecNum;
    }

    /** Returns the employee's hire date
     *@return hireDate
     */
    public String getHireDate() {
        return hireDate;
    }

    /** Sets the employee's hire date
     *@param hireDate contains the date the employee was hired
     */
    public void setHireDate(String hireDate) {
        setIsDirty(true);
        this.hireDate = hireDate;
    }

    /** Returns the employee's fire date
     *@return fireDate
     */
    public String getFireDate() {
        return fireDate;
    }

    /** Sets the employee's fire date
     *@param fireDate contains the date the employee was fired
     */
    public void setFireDate(String fireDate) {
        setIsDirty(true);
        this.fireDate = fireDate;
    }

    /** Returns the employee's wage rate (if the employee
     * is paid on a wage basis).
     *@return wageRate
     */
    public double getWageRate() {
        return wageRate;
    }

    /** Sets the employee's wage rate (if the employee
     * is to be paid on a wage basis).
     *@param wageRate contains the wage rate for this employee
     */
    public void setWageRate(double wageRate) {
        setIsDirty(true);
        this.wageRate = wageRate;
    }

    /** Returns the employee's salary (if the employee 
     * is a salaried employee).
     *@return the salary as maintained in the position object if applicable
     */
    public double getSalary() {
        if(this.position != null){
            return position.getSalary();
        }else{
            return 0.00;
        }
    }

//    /* Sets the employee's salary (if the employee 
//     * is a salaried employee).
//     */
//    public void setSalary(double salary) {
//        setIsDirty(true);
//        this.position.setSalary(salary);
//    }
    
    /** Sets the alreadyInDB variable to indicate that 
     * the information contained in this object has been stored in the database
     *@param is indicates if the object has been saved to the DB
     */
    public void setAlreadyInDB(boolean is){
        setIsDirty(true);
        this.alreadyInDB = is;
    }

    /** Returns if the information contained in this object has already been stored in the database
     *@return alreadyInDB
     */
    public boolean isAlreadyInDB() {
        return alreadyInDB;
    }

    /** Returns if information has been changed within this object
     *@return isDirty
     */
    public boolean isIsDirty() {
        return isDirty;
    }

    /** Sets the variable isDirty to indicate that some information has been modified or changed
     *in this object
     *@param isDirty indicates if info has changed
     */
    public void setIsDirty(boolean isDirty) {
        this.isDirty = isDirty;
    }    

    /** Returns the Position object of the employee
     *@return this Employee's PositionBO
     */
    public PositionBO getPosition() {
        return position;
    }

    /** Sets the Position for the Employee
     *@param position contains this employee's position
     */
    public void setPosition(PositionBO position) {
        this.setIsDirty(true);
        this.position = position;
    }

    /** Returns the password for this employee
     *@return password
     */
    public String getPassword() {
        return password;
    }

    /** Sets the password for this employee
     *@param password contains the password for this employee
     */
    public void setPassword(String password) {
        this.setIsDirty(true);
        this.password = password;
    }
    
    /** Validates the password for this employee
     *@param pwd contains the password entered
     *@return if the password is true or not
     */
    public boolean validatePassword(char[] pwd){
        String pwdIn = String.valueOf(pwd);
        boolean isCorrect = false;
        if(pwdIn.equals(this.getPassword())){
            isCorrect = true;
        }
        return isCorrect;
    }

}
